package com.tanhua.model.vo;

import cn.hutool.core.collection.CollUtil;
import com.tanhua.model.mongo.Questionnaire;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.List;

/**
 * @Desciption:test
 * @Create by:金木yan
 * @Date: 2021/12/10 20:07
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class QuestionnaireVo implements Serializable {
    private String id; //问卷id
    private String name; //问卷名称
    private String cover; //问卷封面
    private String level; //级别
    private Integer star;  //星级
    private List<?> questions;  //试题
    private Integer isLock; //是否锁住(0解锁，1锁住)
    private String reportId; //最新报告id

    //构建vo
    public static QuestionnaireVo init(Questionnaire questionnaire, List list) {
        QuestionnaireVo vo = new QuestionnaireVo();
        BeanUtils.copyProperties(questionnaire, vo);
        vo.setId(questionnaire.getId().toHexString());
        if (!CollUtil.isEmpty(list)) {
            vo.setQuestions(list);
        }
        return vo;
    }
}
